<template>
  <div>
    <!--绑定数据 -->
    <van-cell-group>
      <van-field v-model="user.phone" label="手机号" placeholder="请输入手机号" />
    </van-cell-group>
     <van-cell-group>
      <van-field v-model="user.nickname" label="昵称" placeholder="请输入昵称" />
    </van-cell-group>
     <van-cell-group>
      <van-field v-model="user.password" label="密码" placeholder="请输入密码" />
    </van-cell-group>
    <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit" color="#4400CC" @click="register">注册</van-button>
  </div>
  </div>
</template>

<script>
import {Toast} from "vant"
import { reqRegister } from '../../http/api';
export default {
  // 初始化表单数据
  data() {
    return {
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    //注册
    register() {
      reqRegister(this.user).then((res) => {
        // console.log(res);
        if (res.data.code === 200) {
          Toast(res.data.msg);
          //登录
          this.$router.push("/login");
        } 
      });
    },
  },
};
</script>

<style scoped lang="less">
@import "../../less/index.less";
</style>



